﻿using Microsoft.Xna.Framework;
using Syngine.Components.Shapes;

namespace Syngine
{
	/// <summary>
	/// 
	/// </summary>
	public static class RectangleExtensions
	{
		/// <summary>
		/// Determines whether the specified rectangle contains the position.
		/// </summary>
		/// <param name="rectangle">The rectangle.</param>
		/// <param name="position">The position.</param>
		/// <returns>
		///   <c>true</c> if the specified rectangle contains the position; otherwise, <c>false</c>.
		/// </returns>
		public static bool Contains(this Rectangle rectangle, Vector2 position)
		{
			return rectangle.Contains((int)position.X, (int)position.Y);
		}

		/// <summary>
		/// Converts the rectangle to one that is drawable to the screen.
		/// </summary>
		/// <param name="rectangle">The rectangle to convert.</param>
		/// <returns>A <see cref="DrawableRectangle"/> that can be drawn to the screen.</returns>
		public static DrawableRectangle ToDrawable(this Rectangle rectangle)
		{
			return new DrawableRectangle(rectangle);
		}

		/// <summary>
		/// Converts the rectangle to one that is drawable to the screen using the specified <see cref="Color"/>.
		/// </summary>
		/// <param name="rectangle">The rectangle to convert.</param>
		/// <param name="color">The color of the rectangle.</param>
		/// <returns>A <see cref="DrawableRectangle"/> that can be drawn to the screen.</returns>
		public static DrawableRectangle ToDrawable(this Rectangle rectangle, Color color)
		{
			var drawaleRectangle = new DrawableRectangle(rectangle, color);
			drawaleRectangle.Initialize();
			return drawaleRectangle;
		}
	}
}
